/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.venta;

import Model.TiendaM;
import MsSQL.ConMsSQL;
import java.io.InputStream;
import java.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperPrintManager;
import net.sf.jasperreports.view.JRSaveContributor;
import net.sf.jasperreports.view.JRViewer;

/**
 *
 * @author Maryluz
 */
public class frmReportes extends javax.swing.JDialog {

    int x = 1;
    SimpleDateFormat formateador = new SimpleDateFormat("yyyy-MM-dd");
    JDialog jDialogMostrar;
    TiendaM oMT;
    private final String PDF = "PDF (*.pdf)";
    private final String DOC = "DOCX (*.docx)";
    private final String XLS = "Single sheet XLS (*.xls)";
    private final List<String> PERMITTED_FILE_TYPES_LIST = Arrays.asList(PDF, DOC, XLS);

    public frmReportes(java.awt.Frame parent, boolean modal, TiendaM oM) {
        super(parent, modal);
        initComponents();
        oMT = oM;
        txtFecha.setFormats("dd/MM/yyyy");
        txtFecha1.setFormats("dd/MM/yyyy");
        txtFecha2.setFormats("dd/MM/yyyy");
        buttonGroup1.add(btnRepVd4);
        buttonGroup1.add(btnRepVd5);
        buttonGroup1.add(btnRepECaja4);
        setLocationRelativeTo(null);
        setResizable(false);
        txtTienda.setSelectedIndex(1);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        btnRepECaja4 = new javax.swing.JRadioButton();
        jXDatePicker1 = new org.jdesktop.swingx.JXDatePicker();
        jLabel2 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        btnRepVd4 = new javax.swing.JRadioButton();
        txtFecha1 = new org.jdesktop.swingx.JXDatePicker();
        txtFecha2 = new org.jdesktop.swingx.JXDatePicker();
        jLabel3 = new javax.swing.JLabel();
        btnRepVd5 = new javax.swing.JRadioButton();
        txtFecha = new org.jdesktop.swingx.JXDatePicker();
        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        txtTienda = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();

        btnRepECaja4.setFont(new java.awt.Font("Calibri", 1, 16)); // NOI18N
        btnRepECaja4.setText("Reporte de Movimiento de Almacén");
        btnRepECaja4.setEnabled(false);
        btnRepECaja4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRepECaja4ActionPerformed(evt);
            }
        });

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Reporte2.png"))); // NOI18N
        jLabel2.setText("jLabel2");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel5.setBackground(new java.awt.Color(0, 0, 0));
        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel11.setFont(new java.awt.Font("Cambria", 1, 26)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 204, 51));
        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel11.setText("REPORTES");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(112, 112, 112)
                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel11)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btnRepVd4.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        btnRepVd4.setSelected(true);
        btnRepVd4.setText("Venta diaria");
        btnRepVd4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRepVd4ActionPerformed(evt);
            }
        });

        txtFecha1.setEnabled(false);

        txtFecha2.setEnabled(false);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("y");

        btnRepVd5.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        btnRepVd5.setText("Ventas realizas entre");
        btnRepVd5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRepVd5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnRepVd5)
                    .addComponent(btnRepVd4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtFecha1, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                    .addComponent(txtFecha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtFecha2, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRepVd4, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtFecha2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnRepVd5, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtFecha1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel3)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Seleccione tienda :");

        txtTienda.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        txtTienda.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Todas", "Tienda 01", "Tienda 02" }));
        txtTienda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTiendaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(26, Short.MAX_VALUE)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtTienda, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtTienda, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/report.png"))); // NOI18N
        jButton1.setText("VER REPORTE");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(11, 11, 11)
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        //  System.out.print();
        if (x == 1) {
            abrirReporteDiario(txtTienda.getSelectedIndex() + 1, formateador.format(txtFecha.getDate()));
        } else {
            if (x == 2) {
                abrirReporteMovimientos(txtTienda.getSelectedIndex() + 1, formateador.format(txtFecha.getDate()));
            } else {
                if (x == 3) {
                    System.out.print(txtTienda.getSelectedIndex());
                    if (txtTienda.getSelectedIndex() == 0) {
                        abrirReporteEntre( txtFecha1.getDate(), txtFecha2.getDate());
                    } else {
                        abrirReporteEntreTienda(txtTienda.getSelectedIndex() + 1, txtFecha1.getDate(), txtFecha2.getDate());
                    }
                }
            }
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void btnRepVd4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRepVd4ActionPerformed
        x = 1;
        txtFecha1.setEnabled(false);
        txtFecha2.setEnabled(false);
        txtFecha.setEnabled(true);
        txtTienda.setSelectedIndex(1);
    }//GEN-LAST:event_btnRepVd4ActionPerformed

    private void btnRepECaja4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRepECaja4ActionPerformed
        x = 2;
    }//GEN-LAST:event_btnRepECaja4ActionPerformed

    private void btnRepVd5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRepVd5ActionPerformed
        x = 3;
        txtFecha.setEnabled(false);
        txtFecha1.setEnabled(true);
        txtFecha2.setEnabled(true);
    }//GEN-LAST:event_btnRepVd5ActionPerformed

    private void txtTiendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTiendaActionPerformed
        if(btnRepVd4.isSelected() && txtTienda.getSelectedIndex()==0){
            txtTienda.setSelectedIndex(1);
        }
    }//GEN-LAST:event_txtTiendaActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton btnRepECaja4;
    private javax.swing.JRadioButton btnRepVd4;
    private javax.swing.JRadioButton btnRepVd5;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker1;
    private org.jdesktop.swingx.JXDatePicker txtFecha;
    private org.jdesktop.swingx.JXDatePicker txtFecha1;
    private org.jdesktop.swingx.JXDatePicker txtFecha2;
    private javax.swing.JComboBox txtTienda;
    // End of variables declaration//GEN-END:variables

    @SuppressWarnings("CallToThreadDumpStack")
    private void abrirReporteDiario(int id, String fecha) {
        try {
            Connection conexion = ConMsSQL.obtenerConexion();
            ClassLoader cl = getClass().getClassLoader();
            InputStream in = cl.getClass().getResourceAsStream("/View/venta/reportes/rpt_ventaDia.jasper");
            HashMap objHashMap = new HashMap();
            objHashMap.put("fecha", fecha);
            objHashMap.put("idTienda", id); 
//            objHashMap.put("logo", this.getClass().getResourceAsStream("/Image/BOLETA.png"));
//            objHashMap.put("foto", this.getClass().getResourceAsStream("/Image/logo.png"));
            JasperPrint objJasperPrint = JasperFillManager.fillReport(in, objHashMap, conexion);
 //JasperPrintManager.printReport(objJasperPrint, false);
            JRViewer jRViewer = new JRViewer(objJasperPrint);
            List<JRSaveContributor> SaveOptions = Arrays.asList(jRViewer.getSaveContributors());
            Iterator<JRSaveContributor> i = SaveOptions.iterator();

            while (i.hasNext()) {
                JRSaveContributor jsc = i.next();

                if (PERMITTED_FILE_TYPES_LIST.contains(jsc.getDescription())) {
                    continue;
                } else {
                    jRViewer.removeSaveContributor(jsc);
                }
            }

            jDialogMostrar = new JDialog(this, true);
            jDialogMostrar.setTitle("Reporte de las Ventas del Día " + new SimpleDateFormat("dd/MM/yyyy").format(txtFecha1.getDate()));
            jDialogMostrar.setSize(350, 515);
            jDialogMostrar.setLocationRelativeTo(null);
            jDialogMostrar.add(jRViewer);
            jDialogMostrar.setVisible(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, "No Existe Información para mostrar");
            //  e.printStackTrace();
            //            jDialogMostrar.setVisible(false);
            // e.printStackTrace();
        }
    }

    private void abrirReporteMovimientos(int id, String fecha) {
        try {
            Connection conexion = ConMsSQL.obtenerConexion();
            ClassLoader cl = getClass().getClassLoader();
            InputStream in = cl.getClass().getResourceAsStream("/View/venta/rptMovimientos.jasper");
            HashMap objHashMap = new HashMap();
            objHashMap.put("fecha", fecha);
            objHashMap.put("idTienda", id);
            objHashMap.put("logo", this.getClass().getResourceAsStream("/Image/BOLETA.png"));
            objHashMap.put("foto", this.getClass().getResourceAsStream("/Image/logo.png"));
            JasperPrint objJasperPrint = JasperFillManager.fillReport(in, objHashMap, conexion);

            JRViewer jRViewer = new JRViewer(objJasperPrint);
            List<JRSaveContributor> SaveOptions = Arrays.asList(jRViewer.getSaveContributors());
            Iterator<JRSaveContributor> i = SaveOptions.iterator();

            while (i.hasNext()) {
                JRSaveContributor jsc = i.next();

                if (PERMITTED_FILE_TYPES_LIST.contains(jsc.getDescription())) {
                    continue;
                } else {
                    jRViewer.removeSaveContributor(jsc);
                }
            }
            jDialogMostrar = new JDialog(this, true);
            jDialogMostrar.setTitle("Reporte de las Ventas del Día " + new SimpleDateFormat("dd/MM/yyyy").format(txtFecha1.getDate()));
            jDialogMostrar.setSize(350, 515);
            jDialogMostrar.setLocationRelativeTo(null);
            jDialogMostrar.add(jRViewer);
            jDialogMostrar.setVisible(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, "No Existe Información para mostrar");
            //e.printStackTrace();
            //            jDialogMostrar.setVisible(false);
            // e.printStackTrace();
        }
    }

    private void abrirReporteEntre(Date fecha, Date fecha2) {
        try {
            Connection conexion = ConMsSQL.obtenerConexion();
            ClassLoader cl = getClass().getClassLoader();
            InputStream in = cl.getClass().getResourceAsStream("/View/venta/reportes/rpt_ventaDiaTodos.jasper");
            HashMap objHashMap = new HashMap();
            objHashMap.put("fecha", fecha);
            objHashMap.put("fecha2", fecha2);
          //  objHashMap.put("idTienda", id);
            objHashMap.put("responsable", oMT.getNombres());
//            objHashMap.put("logo", this.getClass().getResourceAsStream("/Image/BOLETA.png"));
//            objHashMap.put("foto", this.getClass().getResourceAsStream("/Image/logo.png"));
            JasperPrint objJasperPrint = JasperFillManager.fillReport(in, objHashMap, conexion);

            JRViewer jRViewer = new JRViewer(objJasperPrint);
            List<JRSaveContributor> SaveOptions = Arrays.asList(jRViewer.getSaveContributors());
            Iterator<JRSaveContributor> i = SaveOptions.iterator();

            while (i.hasNext()) {
                JRSaveContributor jsc = i.next();

                if (PERMITTED_FILE_TYPES_LIST.contains(jsc.getDescription())) {
                    continue;
                } else {
                    jRViewer.removeSaveContributor(jsc);
                }
            }

            jDialogMostrar = new JDialog(this, true);
            jDialogMostrar.setTitle("Reporte de las Ventas del Día " + new SimpleDateFormat("dd/MM/yyyy").format(txtFecha1.getDate()));
            jDialogMostrar.setSize(350, 515);
            jDialogMostrar.setLocationRelativeTo(null);
            jDialogMostrar.add(jRViewer);
            jDialogMostrar.setVisible(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, "No Existe Información para mostrar");
            //     e.printStackTrace();
            //            jDialogMostrar.setVisible(false);
            // e.printStackTrace();
        }
    }

    private void abrirReporteEntreTienda(int id, Date fecha, Date fecha2) {
        try {
            Connection conexion = ConMsSQL.obtenerConexion();
            ClassLoader cl = getClass().getClassLoader();
            InputStream in = cl.getClass().getResourceAsStream("/View/venta/reportes/rpt_ventaDiaTienda.jasper");
            HashMap objHashMap = new HashMap();
            objHashMap.put("fecha", fecha);
            objHashMap.put("fecha2", fecha2);
            objHashMap.put("idTienda", id);
            objHashMap.put("responsable", oMT.getNombres());
//            objHashMap.put("logo", this.getClass().getResourceAsStream("/Image/BOLETA.png"));
//            objHashMap.put("foto", this.getClass().getResourceAsStream("/Image/logo.png"));
            JasperPrint objJasperPrint = JasperFillManager.fillReport(in, objHashMap, conexion);

            JRViewer jRViewer = new JRViewer(objJasperPrint);
            List<JRSaveContributor> SaveOptions = Arrays.asList(jRViewer.getSaveContributors());
            Iterator<JRSaveContributor> i = SaveOptions.iterator();

            while (i.hasNext()) {
                JRSaveContributor jsc = i.next();

                if (PERMITTED_FILE_TYPES_LIST.contains(jsc.getDescription())) {
                    continue;
                } else {
                    jRViewer.removeSaveContributor(jsc);
                }
            }

            jDialogMostrar = new JDialog(this, true);
            jDialogMostrar.setTitle("Reporte de las Ventas del Día " + new SimpleDateFormat("dd/MM/yyyy").format(txtFecha1.getDate()));
            jDialogMostrar.setSize(350, 515);
            jDialogMostrar.setLocationRelativeTo(null);
            jDialogMostrar.add(jRViewer);
            jDialogMostrar.setVisible(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, "No Existe Información para mostrar");
            //     e.printStackTrace();
            //            jDialogMostrar.setVisible(false);
            // e.printStackTrace();
        }
    }
}
